<template>
	<view class="container">
		<view style="font-size: 18px;font-weight: bold;color: #51bb88;">{{info.riqi}} 值班人员列表</view>
		
		<uni-forms ref="baseForm" :modelValue="info" border labelWidth="100px" label-position="top">

			<uni-forms-item>
				<uni-row>
					<uni-col :span="4" v-for="(item, idx) in info.zhiban" :key="idx">
						<view class="user-bg">
							<image :src="item.avatar" class="img-avat"></image>
							<view>
								<text>{{item.name}}</text>
							</view>
						</view>
					</uni-col>
				</uni-row>
			</uni-forms-item>
		</uni-forms>
	</view>
</template>

<script>
	import { websock } from '../../net/websock'
	import moment from 'moment'

	export default {
		data() {
			return {
				info: {}
			}
		},
		async onLoad(params) {
			try {
				this.info = await websock.paibanDetail({id: params.id})
				this.info.riqi = moment(this.info.riqi).format('YYYY-MM-DD')
			} catch (err) {
				console.error(err)
			}
		},
		methods: {
			async clickApply() {
				console.log('试试', 111)
				try {
					await websock.addPaiban({id: this.info.id, riqi: this.info.riqi, zhiban: this.info.zhiban})
					uni.$emit('paiban_change')
					uni.navigateBack()
				} catch (err) {
					console.error(err)
					uni.showToast({title: err.message || 'error'})
				}
			},
			clickSelectAuditor() {
				uni.navigateTo({
					url: '/pages/common/contactSelect?selectedUsers=' + JSON.stringify(this.info.zhiban || []),
					events: {
						contactList: data => {
							console.log('select auditor', data)
							this.info.zhiban = data.contactList
						}
					}
				})
			},
		},

	}
</script>

<style>
	@import url("../common/common.css");
</style>
